

public class _最大公约数 {
    public static void main(String[] args) {
        int a = 30;
        int b = 20;
        int i = 0;
        if(a<b){
            i = a;
            a = b;
            b = i;
        }
        int k = a % b;
        while(k!=0){
            a = b;
            b = k;
            k = a%b;
        }
        System.out.println("公约数为"+b);
    }
}